<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    :maskClosable="false"
    switchFullscreen
    @ok="handleOk"
    :okButtonProps="{ class:{'jee-hidden': disableSubmit} }"
    @cancel="handleCancel">
    <template slot="footer">
      <template v-if="disableSubmit">
        <a-button @click="handleCancel">关闭</a-button>
      </template>
      <template v-else>
        <a-button @click="handleClear">清空</a-button>
        <a-button type="primary" ghost @click="handleOk('1')">保存</a-button>
        <a-button type="primary" @click="handleOk('2')">提交</a-button>
      </template>
    </template>
    <logistics-waybill-detail-form ref="realForm" @ok="submitCallback" :disabled="disableSubmit"/>
  </j-modal>
</template>

<script>
  import LogisticsWaybillDetailForm from './LogisticsWaybillDetailForm'
  export default {
    name: 'LogisticsWaybillDetailModal',
    components: {
      LogisticsWaybillDetailForm
    },
    data() {
      return {
        title:'',
        width:1200,
        visible: false,
        disableSubmit: false
      }
    },
    methods:{
      add () {
        this.visible=true
        this.$nextTick(()=>{
          this.$refs.realForm.add();
        })
      },
      edit (record) {
        this.visible=true
        this.$nextTick(()=>{
          this.$refs.realForm.edit(record);
        })
      },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleClear(){
        this.$refs.realForm.handleClear();
      },
      handleOk (waybillStatus) {
        this.$refs.realForm.handleOk_(waybillStatus);
      },
      submitCallback(){
        this.$emit('ok');
        this.visible = false;
      },
      handleCancel () {
        this.close()
      }
    }
  }
</script>